﻿using Microsoft.Owin;
using Owin;
using System.Web.Http;
using Microsoft.Owin.StaticFiles;
using Microsoft.Owin.FileSystems;
using System;
using System.IO;

[assembly: OwinStartup(typeof(ACServerApi.Startup))]
namespace ACServerApi
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Configure WebApi
            using (var config = new HttpConfiguration())
            {
                WebApiConfig.Register(config);
                app.UseWebApi(config);
            }
            // Configure SignalR
            app.MapSignalR();

            var root = AppDomain.CurrentDomain.BaseDirectory;

            app.UseFileServer(new FileServerOptions()
                {
                    EnableDefaultFiles = true,
                    RequestPath = new PathString(),
                    FileSystem = new PhysicalFileSystem(Path.Combine(root, "StaticFiles"))
                });

            app.UseFileServer(new FileServerOptions()
                {
                    //EnableDirectoryBrowsing = true,
                    RequestPath = new PathString("/Scripts"),
                    FileSystem = new PhysicalFileSystem(Path.Combine(root, "Scripts"))
                });
            app.UseFileServer(new FileServerOptions()
                {
                    RequestPath = new PathString("/Content"),
                    FileSystem = new PhysicalFileSystem(Path.Combine(root, "Content"))
                });
            app.UseFileServer(new FileServerOptions()
                {
                    RequestPath = new PathString("/Fonts"),
                    FileSystem = new PhysicalFileSystem(Path.Combine(root, "Fonts"))
                });
        }
    }
}
